<template>
  <el-row :gutter="0">
    <el-col :span="3">
      <div class="side-content"></div>
    </el-col>
    <el-col :span="21">
      <sn-row-has-two-col
          class="header-bar"
          :left="4"
          :right="20">
        <div slot="one-col" class="to-flex address">
          <span class="cinema-icon">
            Future
          </span>
          <sn-text
              :move-right="30"
              :font-size="16"
              text="成都"
              font-color="#fff"/>
        </div>
        <el-menu
            slot="two-col"
            :default-active="$store.getters.getHomeNavActiveIndex"
            mode="horizontal"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b">
          <el-menu-item index="1" @click="toHome">首页</el-menu-item>
          <el-menu-item index="2" @click="toMovieList">电影</el-menu-item>
          <el-menu-item index="3" @click="toCinema">影院</el-menu-item>
          <el-menu-item index="4" @click="toMonthlyFocus">榜单</el-menu-item>
          <el-menu-item index="5" @click="toCoupon">优惠</el-menu-item>
          <el-menu-item
              class="login"
              index="6"
              @click="toLogin"
              v-if="$store.state.user.userId === 0">
            登录
          </el-menu-item>
          <el-menu-item
              v-if="$store.state.user.userId === 0"
              @click="toRegister"
              class="register"
              index="7">
            注册
          </el-menu-item>

          <!--用户登录-->
          <el-submenu index="8" v-else class="user-info">
            <template slot="title">
              <el-avatar :src="$store.getters.getUser.userImage"></el-avatar>
            </template>
            <el-menu-item index="2-1" @click="toMyOrder">我的订单</el-menu-item>
            <el-menu-item index="2-2" @click="toBasicInfo">基本信息</el-menu-item>
            <el-menu-item index="2-3" @click="exit">退出登录</el-menu-item>
          </el-submenu>
        </el-menu>
      </sn-row-has-two-col>
    </el-col>
  </el-row>
</template>

<script>
export default {
  name: 'HeaderBar',
  data() {
    return {
      movieIcon: require('@/assets/image/home/sidebar/movieInfo.png'),
    };
  },
  methods: {
    //首页
    toHome() {
      this.$router.push({name: 'home'})
    },
    //影院
    toCinema() {
      this.$router.push({name: 'cinema'})
    },
    //电影
    toMovieList() {
      this.$router.push({name: 'movieList'})
    },
    //榜单
    toMonthlyFocus() {
      this.$router.push({name: 'movieMonthlyFocus'})
    },
    //商城
    toCoupon() {
      this.$router.push({name: 'couponList'})
    },
    //登录
    toLogin() {
      this.$router.push({name: 'login'})
    },
    //注册
    toRegister() {
      this.$router.push({name: 'register'})
    },
    // 路由我的订单
    toMyOrder() {
      this.$router.push({name: "meOrder"})
    },
    //路由基础信息
    toBasicInfo() {
      this.$router.push({name: 'basicInfo'})
    },
    //退出
    exit() {
      this.$store.commit(this.mutationsTypes.EXIT_LOGIN)
      this.$router.replace({
        name: 'home'
      })
    }
  }
}
</script>

<style scoped>
.side-content {
  min-height: 60px;
  background-color: #545c64;
}

.address {
  line-height: 60px;
  background-color: #545c64;
}

.movie-icon {
  width: 100px;
  height: 60px;
}

.cinema-icon {
  color: #F66C6C;
  font-size: 30px;
  font-style: italic;
}

.login {
  position: absolute;
  right: 68px;
}

.register {
  position: absolute;
  right: 0;
}

.login-link {
  line-height: 60px;
  font-size: 16px;
}

.user-info {
  position: absolute;
  right: 0;
}
</style>